﻿Public Class UserInfo

    Public Kod As Integer
    Public Ad, Soyad As String
    Public Birim As Integer = -1
    Public IsOperator As Boolean
    Public IsManager As Boolean

    Public MustChangePassword As Boolean
    Public InvalidPassword As Boolean

    Sub Open(ByVal Kod As String, ByVal Password As String)
        If Kod = 0 Then Exit Sub
        Me.Kod = Kod
        Dim Rs = OpenSQL("select * from personel where kod = @kod", Kod)
        Ad = Rs("adi")
        Soyad = Rs("soyadi")
        If Not NoLog() Then
            If IsDBNull(Rs("password")) Then
                MustChangePassword = True
            ElseIf EncrDecr(False, Rs("password")) <> Password Then
                InvalidPassword = True
            End If
        End If
        If Not IsDBNull(Rs("sorumlu")) Then
            Birim = Rs("sorumlu")
            IsOperator = True
        End If
        If Not IsDBNull(Rs("yonetici")) Then
            Birim = Rs("yonetici")
            IsManager = True
        End If
        If Birim = -1 Then Birim = Rs("birim")
    End Sub

End Class
